package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.channels.MulticastChannel;

@Slf4j
@RestController
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;
/*    @PostMapping("/upload")
    public Result upload(String username, Integer age, MultipartFile image){
        log.info("文件上传：{},{},{}",username,age,image);

        //

        return Result.success();
    }*/

    @PostMapping("/upload")
    public Result upload(MultipartFile image)throws IOException {
        String url = aliOSSUtils.upload(image);//调用阿里云工具类，将文件存入阿里云
        return Result.success(url);
    }
}
